package com.zhixinglu.spring.boot.thread.controller;

import com.zhixinglu.spring.boot.thread.threadpool.NamedThreadPool;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * TestController
 * </p>
 *
 * @author weixin
 * @date 2023/3/24 10:30
 */
@Slf4j
@RestController
public class TestController {

    @Resource
    private NamedThreadPool threadPool;

    @GetMapping("test")
    public void test() {
        for (int i = 0; i < 100; i++) {
            threadPool.execute(() -> {
                // 这里是任务代码
                log.info("task-thread is running, task-id name is {}", Thread.currentThread().getName());
            }, "task-thread" + i);
        }
    }
}
